Digital object unique identifier (doi) recognition method and device

ABSTRACT

This application discloses a digital object unique identifier (DOI) recognition method and device. The method comprises: obtaining a code scanning image; graying the code scanning image to obtain a grayscale value of each pixel in the code scanning image; determining a DOI image in the code scanning image according to the grayscale value of each pixel in the code scanning image; and recognizing the DOI image.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation application of International PatentApplication No. PCT/CN2017/097957, filed on Aug. 18, 2017, which isbased on and claims priority to Chinese Patent Application201610787281.9, filed on Aug. 30, 2016, and entitled “DIGITAL OBJECTUNIQUE IDENTIFIER (DOI) RECOGNITION METHOD AND DEVICE.” Theabove-referenced applications are incorporated herein by reference intheir entirety.

TECHNICAL FIELD

This application relates to the field of computer technologies, and inparticular, to a DOI recognition method and device.

BACKGROUND

A digital object unique identifier (DOI), as an identifier of adigitalized object, is equivalent to an identity card of a person, andis unique for an identified digital object. Such a feature ensures thatthe digitalized object is accurately extracted in a network environment,effectively avoiding repetition. A DOI of a digitalized object does notchange once being generated, and does not change with attributes such asan owner of the copyright and a storage address of the digitalizedobject identified by the DOI.

In actual applications, barcodes or two-dimensional codes widely used bypeople are DOIs. For example, as shown in FIG. 1a and FIG. 1b , theimage shown in FIG. 1a is a barcode, and the image shown in FIG. 1b is atwo-dimensional code. Sometimes, an image in which a barcode or atwo-dimensional code is located does not only include the barcode or thetwo-dimensional code, but also includes other patterns, for example, asshown in FIG. 1c and FIG. 1 d.

When a user performs code scanning by using code scanning software, thecode scanning software saves an image within a code scanning frame(which is referred to as a code scanning image hereafter) locally, thenbinarizes the code scanning image, performs corresponding processingafter binarization, and finally recognizes the barcode or thetwo-dimensional code. When a user scans the barcode or thetwo-dimensional code shown in FIG. 1c or FIG. 1d by using the codescanning software, due to a relatively long distance or other reasons,an image within the code scanning frame may include not only the barcodeor the two-dimensional code, but also a pattern other than the barcodeor the two-dimensional code. Therefore, when binarizing the codescanning image, the code scanning software needs to binarize the regionof the barcode or the two-dimensional code, as well as the region of anon-barcode or a non-two-dimensional code. This consumes a relativelylonger processing time and a relatively larger quantity of processingresources, compared with merely processing the region of the barcode orthe two-dimensional code.

SUMMARY

Embodiments of this application provide a DOI recognition method anddevice, to resolve a problem in the existing technology that when a codescanning image includes both a DOI image and a non-DOI image, timeconsumed in recognizing the DOI image in the code scanning image isrelatively long.

The following technical solutions are used in the embodiments of thisapplication:

According to one aspect, a digital object unique identifier (DOI)recognition method comprises:

obtaining a code scanning image;

graying the code scanning image to obtain a grayscale value of eachpixel in the code scanning image;

determining a DOI image in the code scanning image according to thegrayscale value of each pixel in the code scanning image; and

recognizing the DOI image.

In some embodiments, determining a DOI image in the code scanning imagecomprises: determining an average grayscale value of all of the pixelsin the code scanning image; for grayscale values that are not smallerthan the average grayscale value or for grayscale values that are notgreater than the average grayscale value, determining a correspondencebetween each of the grayscale values and a quantity of pixels having thegrayscale value; determining, according to the correspondence, agrayscale value corresponding to a maximum quantity of pixels in thecorrespondence, to be a maximum grayscale value; for the maximumgrayscale value, determining a sub image boundary according to pixelswhose grayscale values are the maximum grayscale value, and determiningone or more sub images within the sub image boundary in the codescanning image; and determining the DOI image in the sub images.

In other embodiments, determining the DOI image in the sub imagescomprises: selecting a sub image of a preset shape from the sub imagesto be the determined DOI image.

In still other embodiments, determining a sub image boundary comprises:determining a rectangular sub image boundary; and selecting a sub imageof a preset shape from the sub images comprises: selecting, according tolength-width ratios of the sub images, a sub image whose length-widthratio falls within a preset range.

In yet other embodiments, determining the DOI image in the sub imagescomprises: for each of the sub images, determining a ratio of quantitiesof pixels having different grayscale values in the sub image; and in thesub images, selecting a sub image for which the determined ratio is of apreset value to be the determined DOI image.

In other embodiments, determining a ratio of quantities of pixels havingdifferent grayscale values in the sub image comprises: determining aratio of the quantity of pixels whose grayscale values are smaller thanthe average grayscale value to the quantity of pixels whose grayscalevalues are greater than the average grayscale value in the sub image.

In still other embodiments, the DOI image comprises at least one of abarcode and a two-dimensional code.

According to another aspect, a digital object unique identifier (DOI)recognition device comprises: one or more processors and one or morenon-transitory computer-readable memories coupled to the one or moreprocessors and configured with instructions executable by the one ormore processors to cause the device to perform operations comprising:obtaining a code scanning image; graying the code scanning image toobtain a grayscale value of each pixel in the code scanning image;determining a DOI image in the code scanning image according to thegrayscale value of each pixel in the code scanning image; andrecognizing the DOI image.

According to yet another aspect, a non-transitory computer-readablestorage medium storing instructions executable by one or more processorsto cause the one or more processors to perform operations comprising:obtaining a code scanning image; graying the code scanning image toobtain a grayscale value of each pixel in the code scanning image;determining a DOI image in the code scanning image according to thegrayscale value of each pixel in the code scanning image; andrecognizing the DOI image.

At least one of the foregoing technical solutions used in theembodiments of this application can achieve the following beneficialeffects:

When a code scanning image not only includes a DOI image, but alsoincludes a non-DOI image, by using the DOI recognition method providedin the embodiments of this application, the code scanning image can begrayed, to obtain grayscale values of pixels in the code scanning image,a DOI image in the code scanning image is determined according to thegrayscale values, and further, the DOI image is recognized. Therefore,the DOI recognition method provided in the embodiments of thisapplication can resolve the problem in the existing technology that whena code scanning image includes both a DOI image and a non-DOI image,time consumed in recognizing the DOI image in the code scanning image isrelatively long.

BRIEF DESCRIPTION OF THE DRAWINGS

The accompanying drawings described herein are used to provide a furtherunderstanding of this application, and form part of this application.Embodiments of this application and descriptions thereof are used toexplain this application, and do not constitute any inappropriatelimitation to this application. In the accompanying drawings:

FIG. 1a shows a barcode image in the existing technology;

FIG. 1b shows a two-dimensional code image in the existing technology;

FIG. 1c shows an image including both a barcode image and a non-barcodeimage in the existing technology;

FIG. 1d shows an image including both a two-dimensional code image and anon-two-dimensional code image in the existing technology;

FIG. 2a is a flowchart of a DOI recognition method according to anembodiment of this application;

FIG. 2b is a flowchart of a method for determining a DOI image accordingto an embodiment of this application;

FIG. 2c is a grayscale histogram of a code scanning image according toan embodiment of this application;

FIG. 2d shows a determined DOI image according to an embodiment of thisapplication; and

FIG. 3 is a schematic structural diagram of a DOI recognition deviceaccording to an embodiment of this application.

DETAILED DESCRIPTION OF THE APPLICATION

To make objectives, technical solutions, and advantages of thisapplication clearer, the following clearly and completely describes thetechnical solutions of this application with reference to embodimentsand corresponding accompanying drawings of this application. Apparently,the described embodiments are merely some but not all of the embodimentsof this application. All other embodiments obtained by a person ofordinary skill in the art based on the embodiments of this applicationwithout creative efforts shall fall within the protection scope of thisapplication.

The following describes in detail the technical solutions provided inthe embodiments of this application with reference to the accompanyingdrawings.

To resolve a problem in the existing technology that when a codescanning image includes both a DOI image and a non-DOI image, timeconsumed in recognizing the DOI image in the code scanning image isrelatively long, an embodiment of this application provides a DOIrecognition method.

An execution body of the method may include, but is not limited to, auser terminal such as a mobile phone, a tablet computer, or a personalcomputer (PC), an application (APP) running on the user terminals, or adevice such as a server.

For convenience of description, the following describes implementationsof the method by using an example in which the execution body of themethod is an APP. It may be understood that the execution body of themethod being an APP is merely an example of description, and should notbe understood as a limitation to the method.

A schematic flowchart of the method is shown in FIG. 2a , including thefollowing steps:

Step 201. Obtain a code scanning image.

In actual applications, when a user scans a DOI image by using a codescanning APP, the APP locally saves an image within a code scanningframe, namely, the code scanning image, for convenience of performing asubsequent corresponding operation to recognize the DOI image in thecode scanning image. The DOI image includes, but is not limited to, abarcode, a two-dimensional code, or the like.

Step 202. Gray the code scanning image, to obtain a grayscale value ofeach pixel in the code scanning image.

Before graying the code scanning image, the APP may first obtain colorchannel information of each pixel in the code scanning image, and thengray the code scanning image according to the color channel information.

In actual applications, a color standard of an image is usually in anRGB color mode. R, G, and B respectively represent colors of threechannels: a red channel, a green channel, and a blue channel. The RGBcolor mode allocates a strength value ranging from 0 to 255 to R, G, andB components of each pixel. For example, the pure red R value is 255,the G value is 0, and the B value is 0. Only three colors are used foran RGB image, to enable the three colors to be mixed according todifferent ratios, and show different colors on a screen.

The obtaining color channel information of each pixel in the codescanning image is to obtain an R value, a G value, and a B value of eachpixel in the code scanning image.

The graying process is that in an RGB color model, an R value, a Gvalue, and a B value of each pixel are converted into an R value, a Gvalue, and a B value that are equal. The R value, the G value, and the Bvalue obtained after graying are a grayscale value of the pixel.

In some embodiments, an APP can perform weighted averaging on an Rvalue, a G value, and a B value of each pixel in the code scanning imageaccording to a formula: grayscale value=R*a+G*b+B*c, to obtain a value,and use the value as the grayscale value. Then, each pixel in the codescanning image is grayed according to the grayscale value obtained afterweighted averaging, to obtain a relatively reasonable grayscale image.In the formula: grayscale value=R*a+G*b+B*c, a, b, and c are notnegative numbers, and a+b+c=1. Values of a, b, and c may be setaccording to different requirements. For example, grayscalevalue=R*0.299+G*0.587+B*0.114.

Step 203. Determine a DOI image in the code scanning image according tothe grayscale value of each pixel in the code scanning image.

In this application, the DOI image can be determined in the codescanning image by using a feature of the DOI image.

For example, if the DOI image is a two-dimensional code, the APP candetermine the two-dimensional code in the code scanning image accordingto a feature of the two-dimensional code. The two-dimensional code is ablack and white checkered pattern distributed in a plane according to aparticular geometrical arrangement. Generally, the two-dimensional codeoccupies most area of the entire code scanning image, and thetwo-dimensional code is generally located in a central region of thecode scanning image. In addition, the two-dimensional code is of aparticular shape, and may be of a square shape, a circular shape, or thelike. This is not limited in this embodiment of this application. Agrayscale value of a pixel having a relatively dark color and formingthe two-dimensional code is generally the smallest or a smallergrayscale value in the code scanning image, and a grayscale value of apixel having a relatively light color and forming the two-dimensionalcode is generally the largest or a larger grayscale value in the codescanning image. If a non-two-dimensional code region in the codescanning image has a relatively light color, the two-dimensional codecan further be determined by searching the code scanning image for animage formed by pixels having a relatively dark color. If anon-two-dimensional code region in the code scanning image has arelatively dark color, the two-dimensional code can further bedetermined by searching the code scanning image for an image formed bypixels having a relatively light color.

If the DOI image is a barcode, the APP can determine the barcode in thecode scanning image according to a feature of the barcode. The barcodeis a pattern identifier formed by arranging, according to an encodingrule, a plurality of black strips and white strips having differentwidths, and used to express a group of information. A common barcode isa pattern formed by parallel black strips and white strips whosereflectivity differs a lot. Generally, the barcode occupies most area ofthe entire code scanning image, and the barcode is generally located ina central region of the code scanning image. In addition, the barcode isgenerally rectangular. A length of the barcode in a horizontal directionis longer than a length in a vertical direction. A grayscale value of apixel having a relatively dark color and forming the barcode isgenerally the smallest or a smaller grayscale value in the code scanningimage, and a grayscale value of a pixel having relatively light colorand forming the barcode is generally the largest or a larger grayscalevalue in the code scanning image. If a non-barcode region in the codescanning image has a relatively light color, the barcode can further bedetermined by searching the code scanning image for a rectangular imageformed by pixels having a relatively dark color. If a non-barcode regionin the code scanning image has a relatively dark color, the barcode canfurther be determined by searching the code scanning image for arectangular image formed by pixels having a relatively light color.

Therefore, the APP can determine the DOI image in the code scanningimage according to a feature on grayscale of the DOI image.

Step 204. Recognize the DOI image.

The APP can binarize the determined DOI image, then perform relatedprocessing, and finally recognize the DOI image. Binarization is to setgrayscale values of pixels on an image to A or B, where A and B may be 0or a positive integer. For example, if A=0, and B=255, binarization isto cause an entire image to be present as merely obvious black and whitevisual effect.

In the DOI recognition method provided in this application, the APPbinarizes the DOI image, performs corresponding processing on thebinarized DOI image, and finally recognizes the DOI image. In a DOIrecognition method in the existing technology, not only a DOI image isbinarized, but also an entire code scanning image is binarized,corresponding processing is performed on the entire binarized codescanning image, and finally the DOI image is recognized. Therefore, theDOI recognition method provided in this application consumes a shorterperiod of time in both binarization and other subsequent correspondingoperations than the existing technology does. In addition, time consumedin binarization is not in a simple linear proportional relationship witha size of an image. For example, a sum of time consumed in merelybinarizing the two-dimensional code in FIG. 1d and time consumed inmerely binarizing the non-two-dimensional code in FIG. 1d is greatlyshorter than time consumed in binarizing the entire image shown in FIG.1d . The operation of determining the DOI image in the code scanningimage in this embodiment of this application is a simple imagepreprocessing process, and consumes a very short period of time.Therefore, compared with the existing technology, the DOI recognitionmethod provided in this embodiment of this application consumes ashorter period of time in recognizing a DOI.

After the overall procedure of recognizing a DOI has been described inthe embodiments of this application, the following describes how todetermine the DOI image in the code scanning image in the step 203. Theprocedure of determining the DOI image is shown in FIG. 2b , includingthe following steps:

Sub step 2031. Determine an average grayscale value of all of the pixelsin the code scanning image.

The APP can obtain a quantity of pixels in the code scanning image, anddetermine the average grayscale value of the pixels in the code scanningimage according to the grayscale values of the pixels in the codescanning image, so that the APP can determine the DOI image according toa feature on grayscale of the DOI image.

Sub step 2032. for the grayscale values that are not smaller than theaverage grayscale value or for the grayscale values that are not greaterthan the average grayscale value, determine a correspondence betweeneach of the grayscale values and a quantity of pixels having thegrayscale value.

The correspondence between the grayscale value and the quantity ofpixels that is described in this application may be a functionrelationship between the quantity of pixels and the grayscale value. Thefunction relationship may be represented as a continuous function, ormay be represented as a discrete function. In some embodiments, aftergraying the code scanning image, the APP may obtain a grayscalehistogram of the code scanning image. The grayscale histogram is afunction related to distribution of grayscale values, that is, adiscrete function between the grayscale value and the quantity ofpixels. For example, as shown in FIG. 2c , the image shown in FIG. 2c isa grayscale histogram. A horizontal coordinate of the grayscalehistogram represents a grayscale value, and a vertical coordinaterepresents the quantity of pixels.

The correspondence between the grayscale value that is not smaller thanthe average grayscale value and the quantity of pixels having thegrayscale value or the correspondence between the grayscale value thatis not greater than the average grayscale value and the quantity ofpixels having the grayscale value may be a function relationship betweenthe grayscale value and the quantity of pixels having the grayscalevalue. Therefore, the correspondence between the grayscale value and thequantity of pixels having the grayscale value can be determinedaccording to the grayscale histogram of the code scanning image and theaverage grayscale value.

Generally, the DOI image is the part having the deepest or relativelydeeper color in the code scanning image. Generally, a smaller grayscalevalue indicates a darker color of a pixel corresponding to the grayscalevalue. Therefore, in the code scanning image, an approximate position ofthe DOI image in the code scanning image can be determined bydetermining a correspondence between the grayscale value that is notgreater than the average grayscale value and the quantity of pixelshaving the grayscale value, to facilitate the APP to subsequentlydetermine the DOI image.

If a smaller grayscale value indicates a lighter color of a pixelcorresponding to the grayscale value, an approximate position of the DOIimage in the code scanning image can be determined by determining acorrespondence between the grayscale value that is not smaller than theaverage grayscale value in the code scanning image and the quantity ofpixels having the grayscale value, to facilitate the APP to subsequentlydetermine the DOI image.

Sub step 2033. Determine, according to the correspondence, a grayscalevalue corresponding to a maximum quantity of pixels in thecorrespondence, to be a maximum grayscale value.

If the correspondence determined through the sub step 2032 is thecorrespondence between the quantity of pixels and the grayscale valuethat is not greater than the average grayscale value, the maximumquantity of pixels can be determined according to the functionrelationship between the quantity of pixels and the grayscale value thatis not greater than the average grayscale value. A grayscale valuecorresponding to the maximum quantity of pixels is the maximum grayscalevalue. There may be one maximum grayscale value or at least two maximumgrayscale values. This is related to an DOI image in actualapplications.

Generally, the DOI image is the part having the deepest or relativelydeeper color in the code scanning image, and the DOI image occupies mostpart of the region of the code scanning image. Therefore, the DOI imagecan be further determined by determining the maximum grayscale value.

Sub step 2034. For the maximum grayscale value, determine a sub imageboundary according to pixels whose grayscale values are the maximumgrayscale value, and determine one or more sub images within the subimage boundary in the code scanning image.

In the code scanning image, a sub image formed by the pixelscorresponding to the maximum grayscale value can be determined. The subimage may be the DOI image. Before the sub image is determined, the subimage boundary may be first determined. Because different DOI imageshave different shapes, methods for determining a sub image boundary aredifferent. The following respectively describes the method fordetermining a sub image boundary in different cases.

In a first case, when the DOI image is a two-dimensional code, the APPmay determine the sub image boundary according to the following method:

If the two-dimensional code is square, the APP may frame the pixelscorresponding to the maximum grayscale value in a rectangular box. Thepixels corresponding to the maximum grayscale value at the outermostedges in four directions, namely, the upper direction, the lowerdirection, the left direction, and the right direction in the codescanning image are exactly distributed on four sides of the rectangularbox. A boundary corresponding to the rectangular box may serve as thesub image boundary. Alternatively, the APP may determine the pixelscorresponding to the maximum grayscale value at the outermost edges infour directions, namely, the upper direction, the lower direction, theleft direction, and the right direction in the code scanning image, andthen determine the sub image boundary according to the pixels. Forexample, the APP determines pixels corresponding to the maximumgrayscale value on the leftmost side in the code scanning image, anddetermines a vertical line going through the pixels. The vertical lineis the boundary on the leftmost side of the sub image. The APPdetermines pixels corresponding to the maximum grayscale value on thelowermost side in the code scanning image, and determines a horizontalline going through the pixels. The horizontal line is the boundary onthe lowermost side of the sub image. Similarly, the APP may determineboundaries of the rightmost side and the uppermost side of the subimage. In this way, the boundary of the sub image is determined.

If the two-dimensional code is round or of another shape, the APP maydetermine a minimum region that can cover all pixels corresponding tothe maximum grayscale value and that is of the same shape of that of thetwo-dimensional code, and then use a boundary of the minimum region asthe sub image boundary.

In a second embodiment, when the DOI image is a barcode, the APP maydetermine the sub image boundary according to the following method:

If the barcode is rectangular, the APP may frame the pixelscorresponding to the maximum grayscale value in a rectangular box. Thepixels corresponding to the maximum grayscale value at the outermostedges in four directions, namely, the upper direction, the lowerdirection, the left direction, and the right direction in the codescanning image are exactly distributed on four sides of the rectangularbox. A boundary corresponding to the rectangular box may serve as thesub image boundary.

In this embodiment of this application, a shape of a DOI image that isto be operated may be preset, to facilitate the APP to determine the subimage boundary by using a proper method.

After the sub image boundary is determined, the sub images in the codescanning image within the sub image boundary may be determined. Theremay be one or at least two sub images.

Sub step 2035. Determine the DOI image in the sub images.

After the sub images are determined, the APP may determine the DOI imagein the sub images according to a feature of a DOI. The APP may select asub image of a preset shape according to shapes of the sub images, to bethe determined DOI image. For example, when the DOI image is atwo-dimensional code, if the determined sub image boundary isrectangular, the APP may select, according to length-width ratios of thesub images, a sub image whose length-width ratio falls within a presetlength-width ratio range, to be the two-dimensional code. The presetratio may be a value, or may be a range. This is not limited in thisembodiment of this application. Sometimes, there may be more than onesub image whose length-width ratio falls within the preset length-widthratio range, for example, at least two, etc. In some embodiments, a subimage whose length-width ratio is the closest to 1 is determined as thetwo-dimensional code. The reason is that generally, the two-dimensionalcode is square or round. Therefore, a length-width ratio of thetwo-dimensional code should be 1. For example, if the APP is todetermine the two-dimensional code image shown in FIG. 1d , thetwo-dimensional code image determined through the sub step 2031 to thesub step 2035 may be shown in FIG. 2 d.

When the DOI image is a barcode, if the determined sub image boundary isrectangular, and if the length-width ratio of the sub image satisfies apreset length-width ratio, for example, the preset length-width ratio is1 to 100, it is determined that the sub image is a barcode. If there areat least two sub images satisfying this condition, one of the sub imagesis randomly selected to serve as the barcode.

In addition to determining the DOI image according to the shapes of thesub images, the APP may further determine the DOI image according toquantity ratios of pixels. For example, for each of the sub images, theAPP determines ratios of quantities of pixels having different grayscalevalues in the sub image; and in the sub images, selects a sub image forwhich a ratio of the quantities of pixels is of a preset value to be thedetermined DOI image. The determining quantity ratios of pixels havingdifferent grayscale values in the sub image may be determining a ratioof the quantity of pixels whose grayscale values are smaller than theaverage grayscale value in the sub image to the quantity of pixels whosegrayscale values are greater than the average grayscale value, or, thequantity ratios of pixels may be ratios of quantities of pixels of allgrayscale values. For example, when the DOI image is a two-dimensionalcode or a barcode, a ratio of the quantity of pixels whose grayscalevalues are smaller than the average grayscale value to the quantity ofpixels whose grayscale values are greater than the average grayscalevalue in the two-dimensional code and that in the barcode is basically1:1. A sub image in which a ratio of the quantity of pixels whosegrayscale values are smaller than the average grayscale value to thequantity of pixels whose grayscale values are greater than the averagegrayscale value is the closest to 1:1 is determined as thetwo-dimensional code or the barcode.

In some embodiments, the APP may determine the DOI image bysimultaneously using the foregoing two methods, or may determine the DOIimage by using one of the methods. This is not limited in thisapplication.

In this embodiment of this application, the APP may further determinethe sub image boundary by using the following method, and furtherdetermine the DOI image. After determining the average grayscale valueof the code scanning image, the APP may determine all grayscale valueswithin a range of the average grayscale value±d, respectively determine,for the grayscale values, pixels corresponding to the grayscale values,determine a sub image boundary corresponding to the pixels, and then,determine the DOI image according to the foregoing method fordetermining a DOI, where “d” is a preset value, and may be any positiveinteger, and a value corresponding to the average grayscale value±d iswithin 0 to 255.

In the embodiments of this application, the DOI recognition methodprovided in the embodiments of this application may be implemented byusing a DOI recognition device.

FIG. 3 is a schematic structural diagram of a DOI recognition deviceaccording to an embodiment of this application, mainly including thefollowing modules:

an image obtaining module 31, configured to obtain a code scanningimage;

a grayscale value obtaining module 32, configured to gray the codescanning image, to obtain a grayscale value of each pixel in the codescanning image;

an image determining module 33, configured to determine a DOI image inthe code scanning image according to the grayscale value of each pixelin the code scanning image; and

an image recognition module 34, configured to recognize the DOI image.

In an implementation, the image determining module 33 is configured to:determine an average grayscale value of all of the pixels in the codescanning image;

for the grayscale values that are not smaller than the average grayscalevalue or for the grayscale values that are not greater than the averagegrayscale value, determining a correspondence between each of thegrayscale values and a quantity of pixels having the grayscale value;

determine, according to the correspondence, a grayscale valuecorresponding to a maximum quantity of pixels in the correspondence, tobe a maximum grayscale value;

for the maximum grayscale value, determine a sub image boundaryaccording to pixels, whose grayscale values are the maximum grayscalevalue, and determine one or more sub images within the sub imageboundary in the code scanning image; and

determine the DOI image in the sub images.

In an implementation, the image determining module 33 is configured to:select a sub image of a preset shape according to shapes of the subimages, to be the determined DOI image; and/or

for each of the sub images, determining a ratio of quantities of pixelshaving different grayscale values in the sub image; and in the subimages, selecting a sub image for which the determined ratio is of apreset value to be the determined DOI image.

In an implementation, the image determining module 33 is configured to:determine a rectangular sub image boundary; and

select, according to length-width ratios of the sub images, a sub imagewhose length-width ratio falls within a preset length-width ratio range.

In an implementation, the image determining module 33 is configured todetermining a ratio of the quantity of pixels whose grayscale values aresmaller than the average grayscale value to the quantity of pixels whosegrayscale values are greater than the average grayscale value in the subimage.

In an implementation, the DOI image includes at least one of a barcodeand a two-dimensional code.

When a code scanning image not only includes a DOI image, but alsoincludes a non-DOI image, by using the DOI recognition method providedin the embodiments of this application, the code scanning image can begrayed, to obtain grayscale values of pixels in the code scanning image,a DOI image in the code scanning image is determined according to thegrayscale values, and further, the DOI image is recognized. Therefore,the DOI recognition method provided in this embodiment of thisapplication can resolve the problem in the existing technology that whena code scanning image includes both a DOI image and a non-DOI image,time consumed in recognizing the DOI image in the code scanning image isrelatively long.

A person skilled in the art should understand that the embodiments ofthe specification may be provided as a method, a system, or a computerprogram product. Therefore, the invention may use a form of hardwareonly embodiments, software only embodiments, or embodiments with acombination of software and hardware. Moreover, the invention may use aform of a computer program product that is implemented on one or morecomputer-usable storage media (including but not limited to a diskmemory, a compact disc read-only memory (CD-ROM), an optical memory, andthe like) that include computer-usable program code.

The embodiments are described with reference to flowcharts and/or blockdiagrams of the method, device (system), and the computer programproduct in the specification. It should be understood that computerprogram instructions may be used to implement each process and/or eachblock in the flowcharts and/or the block diagrams and a combination of aprocess and/or a block in the flowcharts and/or the block diagrams.These computer program instructions may be provided for ageneral-purpose computer, a dedicated computer, an embedded processor,or a processor of any other programmable data processing device togenerate a machine, so that the instructions executed by a computer or aprocessor of any other programmable data processing device generate anapparatus for implementing a function in one or more processes in theflowcharts and/or in one or more blocks in the block diagrams.

These computer program instructions may also be stored in a computerreadable memory that can instruct the computer or any other programmabledata processing device to work in a manner, so that the instructionsstored in the computer readable memory generate an artifact thatincludes an instruction apparatus. The instruction apparatus implementsa function in one or more processes in the flowcharts and/or in one ormore blocks in the block diagrams.

These computer program instructions may also be loaded onto a computeror another programmable data processing device, so that a series ofoperations and steps are performed on the computer or the anotherprogrammable device, thereby generating computer-implemented processing.Therefore, the instructions executed on the computer or the anotherprogrammable device provide steps for implementing a function in one ormore processes in the flowcharts and/or in one or more blocks in theblock diagrams.

In a typical configuration, a computing device includes one or moreprocessors (CPU), an input/output interface, a network interface, and amemory.

The memory may include forms such as a volatile memory incomputer-readable mediums, a random access memory (RAM) and/or anon-volatile memory, for example, a read-only memory (ROM) or a flashRAM. The memory is an example of the computer-readable medium.

The computer-readable medium includes permanent and nonpermanent mediumsand movable and non-movable mediums. Information may be stored by usingany method or technology. The information may be a computer-readableinstruction, a data structure, a module of a program, or other data.Examples of a storage medium of a computer includes, but is not limitedto, a phase change memory (PRAM), a static random access memory (SRAM),a dynamic random access memory (DRAM), or other types of random accessmemory (RAM), a read-only memory (ROM), an erasable programmable readonly memory (EEPROM), a flash memory or another storage technology, acompact disc read-only memory (CD-ROM), a digital versatile disc (DVD)or another optical storage, or a cartridge tape. A magnetic storage of amagnetic tape or a disc, another magnetic storage device, or any othernon-transmission medium may be configured to store information that canbe accessed by a computing device. According to the definitions in thisspecification, the computer-readable medium does not include transitorymedia, such as a modulated data signal or carrier.

It should be further noted that the terms “comprise,” “include,” and anyvariants thereof are intended to cover a non-exclusive inclusion.Therefore, a process, method, product, or device that includes a seriesof elements not only includes such elements, but also includes otherelements not specified expressly, or may include inherent elements ofthe process, method, product, or device. Unless otherwise specified, anelement limited by “include a/an . . . ” does not exclude other sameelements existing in the process, the product, the article, or thedevice that includes the element.

A person skilled in the art should understand that the embodiments ofthe present application may be provided as a method, a system, or acomputer program product. Therefore, this application may take the formof total hardware embodiments, total software embodiments, orembodiments combining software and hardware. In addition, thisapplication may take the form of a computer program product implementedon one or more computer-usable storage media (including, but not limitedto, a magnetic storage device, a CD-ROM, and an optical storage device)including computer-usable program code.

The foregoing is merely the embodiments of this application, and is notintended to limit this application. For a person skilled in the art,this application may have various modifications and variations. Anymodifications, equivalent substitutions, and improvements made withinthe spirit and principle of this application shall fall within theprotection scope of claims of this application.

What is claimed is:
 1. A digital object unique identifier (DOI)recognition method, comprising: obtaining a code scanning image; grayingthe code scanning image to obtain a grayscale value of each pixel in thecode scanning image; determining a DOI image in the code scanning imageaccording to the grayscale value of each pixel in the code scanningimage; and recognizing the DOI image.
 2. The method according to claim1, wherein the determining a DOI image in the code scanning imagecomprises: determining an average grayscale value of all of the pixelsin the code scanning image; for grayscale values that are not smallerthan the average grayscale value or for grayscale values that are notgreater than the average grayscale value, determining a correspondencebetween each of the grayscale values and a quantity of pixels having thegrayscale value; determining, according to the correspondence, agrayscale value corresponding to a maximum quantity of pixels in thecorrespondence, to be a maximum grayscale value; for the maximumgrayscale value, determining a sub image boundary according to pixelswhose grayscale values are the maximum grayscale value, and determiningone or more sub images within the sub image boundary in the codescanning image; and determining the DOI image in the sub images.
 3. Themethod according to claim 2, wherein the determining the DOI image inthe sub images comprises: selecting a sub image of a preset shape fromthe sub images to be the determined DOI image.
 4. The method accordingto claim 3, wherein the determining a sub image boundary comprises:determining a rectangular sub image boundary; and wherein the selectinga sub image of a preset shape from the sub images comprises: selecting,according to length-width ratios of the sub images, a sub image whoselength-width ratio falls within a preset range.
 5. The method accordingto claim 2, wherein the determining the DOI image in the sub imagescomprises: for each of the sub images, determining a ratio of quantitiesof pixels having different grayscale values in the sub image; and in thesub images, selecting a sub image for which the determined ratio is of apreset value to be the determined DOI image.
 6. The method according toclaim 5, wherein the determining a ratio of quantities of pixels havingdifferent grayscale values in the sub image comprises: determining aratio of the quantity of pixels whose grayscale values are smaller thanthe average grayscale value to the quantity of pixels whose grayscalevalues are greater than the average grayscale value in the sub image. 7.The method according to claim 1, wherein the DOI image comprises atleast one of a barcode and a two-dimensional code.
 8. A digital objectunique identifier (DOI) recognition device, comprising one or moreprocessors and one or more non-transitory computer-readable memoriescoupled to the one or more processors and configured with instructionsexecutable by the one or more processors to cause the device to performoperations comprising: obtaining a code scanning image; graying the codescanning image to obtain a grayscale value of each pixel in the codescanning image; determining a DOI image in the code scanning imageaccording to the grayscale value of each pixel in the code scanningimage; and recognizing the DOI image.
 9. The device according to claim8, wherein the determining a DOI image in the code scanning imagecomprises: determining an average grayscale value of all of the pixelsin the code scanning image; for grayscale values that are not smallerthan the average grayscale value or for grayscale values that are notgreater than the average grayscale value, determining a correspondencebetween each of the grayscale values and a quantity of pixels having thegrayscale value; determining, according to the correspondence, agrayscale value corresponding to a maximum quantity of pixels in thecorrespondence, to be a maximum grayscale value; for the maximumgrayscale value, determining a sub image boundary according to pixelswhose grayscale values are the maximum grayscale value, and determiningone or more sub images within the sub image boundary in the codescanning image; and determining the DOI image in the sub images.
 10. Thedevice according to claim 9, wherein the determining the DOI image inthe sub images comprises: selecting a sub image of a preset shape fromthe sub images to be the determined DOI image.
 11. The device accordingto claim 10, wherein the determining a sub image boundary comprises:determining a rectangular sub image boundary; and wherein the selectinga sub image of a preset shape from the sub images comprises: selecting,according to length-width ratios of the sub images, a sub image whoselength-width ratio falls within a preset range.
 12. The device accordingto claim 9, wherein the determining the DOI image in the sub imagescomprises: for each of the sub images, determining a ratio of quantitiesof pixels having different grayscale values in the sub image; and in thesub images, selecting a sub image for which the determined ratio is of apreset value to be the determined DOI image.
 13. The device according toclaim 12, wherein the determining a ratio of quantities of pixels havingdifferent grayscale values in the sub image comprises: determining aratio of the quantity of pixels whose grayscale values are smaller thanthe average grayscale value to the quantity of pixels whose grayscalevalues are greater than the average grayscale value in the sub image.14. The device according to claim 8, wherein the DOI image comprises atleast one of a barcode and a two-dimensional code.
 15. A non-transitorycomputer-readable storage medium storing instructions executable by oneor more processors to cause the one or more processors to performoperations comprising: obtaining a code scanning image; graying the codescanning image to obtain a grayscale value of each pixel in the codescanning image; determining a DOI image in the code scanning imageaccording to the grayscale value of each pixel in the code scanningimage; and recognizing the DOI image.
 16. The non-transitorycomputer-readable storage medium according to claim 15, wherein thedetermining a DOI image in the code scanning image comprises:determining an average grayscale value of all of the pixels in the codescanning image; for grayscale values that are not smaller than theaverage grayscale value or for grayscale values that are not greaterthan the average grayscale value, determining a correspondence betweeneach of the grayscale values and a quantity of pixels having thegrayscale value; determining, according to the correspondence, agrayscale value corresponding to a maximum quantity of pixels in thecorrespondence, to be a maximum grayscale value; for the maximumgrayscale value, determining a sub image boundary according to pixelswhose grayscale values are the maximum grayscale value, and determiningone or more sub images within the sub image boundary in the codescanning image; and determining the DOI image in the sub images.
 17. Thenon-transitory computer-readable storage medium according to claim 16,wherein the determining the DOI image in the sub images comprises:selecting a sub image of a preset shape from the sub images to be thedetermined DOI image.
 18. The non-transitory computer-readable storagemedium according to claim 17, wherein the determining a sub imageboundary comprises: determining a rectangular sub image boundary; andwherein the selecting a sub image of a preset shape from the sub imagescomprises: selecting, according to length-width ratios of the subimages, a sub image whose length-width ratio falls within a presetrange.
 19. The non-transitory computer-readable storage medium accordingto claim 16, wherein the determining the DOI image in the sub imagescomprises: for each of the sub images, determining a ratio of quantitiesof pixels having different grayscale values in the sub image; and in thesub images, selecting a sub image for which the determined ratio is of apreset value to be the determined DOI image.
 20. The non-transitorycomputer-readable storage medium according to claim 19, wherein thedetermining a ratio of quantities of pixels having different grayscalevalues in the sub image comprises: determining a ratio of the quantityof pixels whose grayscale values are smaller than the average grayscalevalue to the quantity of pixels whose grayscale values are greater thanthe average grayscale value in the sub image.